package com.jiuqi.component.listener;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class SessionListener implements HttpSessionListener{

	public void sessionCreated(HttpSessionEvent arg0) {
		HttpSession hs = arg0.getSession();
		ServletContext sc = hs.getServletContext();
		Integer i = (Integer)sc.getAttribute("OnLineCount");
		int cnt = i.intValue()+1;
		sc.setAttribute("OnLineCount",new Integer(cnt));
	}

	public void sessionDestroyed(HttpSessionEvent arg0) {
		// TODO Auto-generated method stub
		HttpSession hs = arg0.getSession();
		ServletContext sc = hs.getServletContext();
		Integer i = (Integer)sc.getAttribute("OnLineCount");
		int cnt = i.intValue()-1;
		sc.setAttribute("OnLineCount",new Integer(cnt));
	}

}
